<template>
  <div class="app-container" id="addgoods">
    <div style="background-color: #fff">
      <div class="container-module" style="padding-bottom: 0">
        <el-form :inline="true" class="search-form" size="small">
          <el-row style="display: flex">
            <div style="flex: 1">
              <el-form-item class="search-form-item" label="退款订单号" style="margin: 5px 0">
                <el-input clearable placeholder="请输入退款订单号" v-model="searchForm.refund_order_no"
                  onkeyup="value =value.replace(/[^a-zA-Z0-9]/g, '')" class="input-with-select">
                </el-input>
              </el-form-item>
              <el-form-item v-if="searchDisplay" class="search-form-item" label="订单流水号" style="margin: 5px 0">
                <el-input clearable placeholder="请输入订单流水号" v-model="searchForm.order_trade_no" type="text" min="1"
                  class="input-with-select">
                </el-input>
              </el-form-item>
              <el-form-item v-if="searchDisplay" class="search-form-item" label="支付单号" style="margin: 5px 0">
                <el-input clearable placeholder="请输入支付单号" v-model="searchForm.pay_order_no" type="text" min="1"
                  class="input-with-select">
                </el-input>
              </el-form-item>
              <el-form-item class="search-form-item" v-if="searchDisplay" label="商品名称" style="margin: 5px 0">
                <el-input clearable placeholder="请输入商品名称" v-model="searchForm.goods_name" type="text" min="1"
                  class="input-with-select">
                </el-input>
              </el-form-item>
              <el-form-item class="search-form-item" v-if="searchDisplay" label="支付方式" style="margin: 5px 0">
                <el-select clearable v-model="searchForm.pay_service" placeholder="请选择支付方式">
                  <el-option v-for="item in [
                      { name: '余额支付', id: 1 },
                      { name: '支付宝', id: 2 },
                      { name: '微信', id: 3 },
                    ]" :key="item.id" :label="item.name" :value="item.id">
                  </el-option>
                </el-select>
              </el-form-item>
              <el-form-item class="search-form-item" label="售后状态" style="margin: 5px 0">
                <el-select clearable v-model="searchForm.status" placeholder="请选择售后状态">
                  <el-option v-for="item in [
                      { name: '申请中', id: 1 },
                      { name: '需要重新上传资料', id: 2 },
                      { name: '需要退回商品', id: 3 },
                      { name: '等待退回确认', id: 4 },
                      { name: '商品退回已确认', id: 5 },
                      { name: '商家已重新发货', id: 6 },
                      { name: '用户已确认收货', id: 7 },
                      { name: '售后完成', id: 8 },
                      { name: '驳回', id: 9 },
                      { name: '取消售后', id: 10 },
                    ]" :key="item.id" :label="item.name" :value="item.id">
                  </el-option>
                </el-select>
              </el-form-item>
              <el-form-item class="search-form-item" v-if="searchDisplay" label="用户ID" style="margin: 5px 0">
                <el-input clearable placeholder="请输入用户ID" v-model="searchForm.user_id" class="input-with-select">
                </el-input>
              </el-form-item>
              <el-form-item class="search-form-item" v-if="searchDisplay" label="收货人电话" style="margin: 5px 0">
                <el-input clearable placeholder="请输入收货人电话" v-model="searchForm.phone_number" class="input-with-select">
                </el-input>
              </el-form-item>
              <el-form-item class="search-form-item" v-if="searchDisplay" label="收货人姓名" style="margin: 5px 0">
                <el-input clearable placeholder="请输入收货人姓名" v-model="searchForm.recipient" class="input-with-select">
                </el-input>
              </el-form-item>
              <el-form-item class="search-form-item" v-if="searchDisplay" label="商品ID" style="margin: 5px 0">
                <el-input clearable placeholder="请输入商品ID" v-model="searchForm.goods_id" type="text" min="1"
                  class="input-with-select">
                </el-input>
              </el-form-item>
              <el-form-item class="search-form-item" v-if="searchDisplay" label="商品名称" style="margin: 5px 0">
                <el-input clearable placeholder="请输入商品名称" v-model="searchForm.goods_name" type="text" min="1"
                  class="input-with-select">
                </el-input>
              </el-form-item>

              <el-form-item class="search-form-item" v-if="searchDisplay" label="供货商ID" style="margin: 5px 0">
                <el-input clearable placeholder="请输入供货商ID" v-model="searchForm.supplier_id" type="text" min="1"
                  class="input-with-select">
                </el-input>
              </el-form-item>
              <el-form-item class="search-form-item" v-if="searchDisplay" label="店铺/商户ID" style="margin: 5px 0">
                <el-input clearable placeholder="请输入店铺/商户ID" v-model="searchForm.mer_id" type="text" min="1"
                  class="input-with-select">
                </el-input>
              </el-form-item>
              <el-form-item class="search-form-item" v-if="searchDisplay" label="申请起始时间" style="margin: 5px 0">
                <el-date-picker v-model="create_time" type="datetimerange" @change="create_timeWay"
                  value-format="yyyy-MM-dd HH:mm:ss" :picker-options="pickerOptions" range-separator="至"
                  start-placeholder="开始日期" end-placeholder="结束日期" align="right">
                </el-date-picker>
              </el-form-item>
              <el-form-item class="search-form-item" v-if="searchDisplay" label="审核起始时间" style="margin: 5px 0">
                <el-date-picker v-model="verify_time" type="datetimerange" @change="verify_timeWay"
                  value-format="yyyy-MM-dd HH:mm:ss" :picker-options="pickerOptions" range-separator="至"
                  start-placeholder="开始日期" end-placeholder="结束日期" align="right">
                </el-date-picker>
              </el-form-item>
              <el-form-item class="search-form-item" v-if="searchDisplay" label="退款截至时间" style="margin: 5px 0">
                <el-date-picker v-model="complete_time" type="datetimerange" @change="complete_timeWay"
                  value-format="yyyy-MM-dd HH:mm:ss" :picker-options="pickerOptions" range-separator="至"
                  start-placeholder="开始日期" end-placeholder="结束日期" align="right">
                </el-date-picker>
              </el-form-item>
              <el-form-item class="search-form-item" v-if="searchDisplay" label="支付起始时间" style="margin: 5px 0">
                <el-date-picker v-model="pay_time" type="datetimerange" @change="pay_timeWay"
                  value-format="yyyy-MM-dd HH:mm:ss" :picker-options="pickerOptions" range-separator="至"
                  start-placeholder="开始日期" end-placeholder="结束日期" align="right">
                </el-date-picker>
              </el-form-item>
            </div>
            <div style="padding: 5px 0">
              <el-form-item>
                <el-button size="small" type="primary" icon="el-icon-search" @click="getListWay">查询</el-button>
                <el-button size="small" type="primary" icon="el-icon-refresh" @click="resetting">重置</el-button>
                <el-button v-if="!searchDisplay" icon="el-icon-caret-bottom"
                  @click="searchDisplay = true">展开</el-button>
                <el-button v-else icon="el-icon-caret-top" @click="searchDisplay = false">收起</el-button>
              </el-form-item>
            </div>
          </el-row>
        </el-form>
      </div>
      <el-divider></el-divider>
      <div style="padding: 0 20px 20px">
        <div class="marginBottom">
          <el-row :gutter="20">
            <el-col :span="20"> </el-col>
            <el-col :span="4" style="float: right">
              <div class="right-panel el-button-group">
                <el-button class="" icon="el-icon-refresh" size="mini" @click="getListWay"></el-button>
                <el-dropdown trigger="click" :hide-on-click="false">
                  <span class="el-dropdown-link">
                    <el-button class="" icon="el-icon-s-operation" size="mini"></el-button>
                  </span>
                  <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item v-for="fruit in allTableThead" :key="fruit">
                      <el-checkbox v-model="checkboxTableThead"
                        :label="fruit">{{ tableTheadOptions[fruit].label }}</el-checkbox>
                    </el-dropdown-item>
                  </el-dropdown-menu>
                </el-dropdown>
              </div>
            </el-col>
          </el-row>
        </div>
        <el-row :gutter="20">
          <el-col class="new_table_card">
            <el-table ref="tablerefs" highlight-current-row :data="RefundList" :header-cell-style="{
                'background-color': '#f3f8fe',
                color: '#606266',
                height: '50px',
              }" style="width: 100%" v-loading="loading" height="100%">
              <el-table-column v-for="fruit in tableThead" :key="fruit" :label="tableTheadOptions[fruit].label" :width="
                  tableTheadOptions[fruit].width
                    ? tableTheadOptions[fruit].width + 'px'
                    : 'auto'
                " align="center">
                <template slot-scope="scope">
                  <div v-if="fruit == 'sku_img' || fruit == 'goods_main_image'" style="
                      width: 30px;
                      height: 30px;
                      border-radius: 5px;
                      overflow: hidden;
                      margin: 0 auto;
                    ">
                    <el-image v-if="scope.row[fruit]" :src="scope.row[fruit]" :preview-src-list="[scope.row[fruit]]" />
                  </div>
                  <div v-else-if="fruit == 'apply_imgs'" style="
                      width: 30px;
                      height: 30px;
                      border-radius: 5px;
                      overflow: hidden;
                      margin: 0 auto;
                    ">
                    <el-image :src="scope.row[fruit][0]" :preview-src-list="scope.row[fruit]">
                    </el-image>
                  </div>
                  <div v-else-if="fruit == 'type'" style="color: #0076f6;">
                    <div v-if="scope.row[fruit] == 1">仅退款</div>
                    <div v-if="scope.row[fruit] == 2">退货退款</div>
                    <div v-if="scope.row[fruit] == 3">换货</div>
                  </div>
                  <div v-else-if="fruit == 'addr_province_name'">
                    {{ scope.row.addr_province_name }}
                    {{ scope.row.addr_city_name }}
                    {{ scope.row.addr_district_name }}
                  </div>
                  <div v-else-if="fruit == 'shouhoujilu'">
                    <el-button @click="recordDialogWay(scope.row)" style="margin: 5px" type="text" size="mini">
                      查看
                    </el-button>
                  </div>
                  <span v-else>
                    <el-tooltip placement="top-start" :content="scope.row[fruit] + ''">
                      <div class="one_line_hidden">
                        {{ scope.row[fruit] ? scope.row[fruit] : "-" }}
                      </div>
                    </el-tooltip>
                  </span>
                </template>
              </el-table-column>
              <el-table-column align="center" prop="status" label="状态">
                <template slot-scope="scope">
                  <div v-if="scope.row.status == 1" style="color: #ff4949;">待处理</div>
                  <div v-if="scope.row.status == 2" style="color: #0076f6;">等待客户重新上传资料</div>
                  <div v-if="scope.row.status == 3" style="color: #0076f6;">等待客户寄回商品</div>
                  <div v-if="scope.row.status == 4" style="color: #0076f6;">等待确认商品</div>
                  <div v-if="scope.row.status == 5" style="color: #0076f6;">商品已确认</div>
                  <div v-if="scope.row.status == 6" style="color: #0076f6;">已重新发货</div>
                  <div v-if="scope.row.status == 7" style="color: #0076f6;">客户已确认收货</div>
                  <div v-if="scope.row.status == 8" style="color: #0076f6;">售后完成</div>
                  <div v-if="scope.row.status == 9" style="color: #0076f6;">已驳回</div>
                  <div v-if="scope.row.status == 10" style="color: #0076f6;">已取消售后</div>
                </template>
              </el-table-column>
              <el-table-column align="center" fixed="right" width="160" prop="address" label="操作">
                <template slot-scope="scope">
                  <el-button v-if="scope.row.status == 1 || scope.row.status == 2"
                    v-hasPermi="'platformorder/aftersales/auditing'" type="text" size="mini"
                    @click="drawerHandle(scope.row)">
                    审核
                  </el-button>
                  <el-divider v-if="scope.row.status == 1 || scope.row.status == 2" direction="vertical"></el-divider>
                  <el-button v-if="scope.row.status == 4" v-hasPermi="'platformorder/aftersales/confirm_return'"
                    type="text" size="mini" @click="confirmHandle(scope.row)">
                    确认寄回
                  </el-button>
                  <el-divider v-if="scope.row.status == 4" direction="vertical"></el-divider>
                  <el-button v-if="scope.row.type == 3 && scope.row.status == 5"
                    v-hasPermi="'platformorder/aftersales/confirm_exchange'" type="text" size="mini"
                    @click="exchangeHandle(scope.row)">
                    确认换货
                  </el-button>
                  <el-divider v-if="scope.row.type == 3 && scope.row.status == 5" direction="vertical"></el-divider>
                  <el-button v-if="
                      scope.row.type == 2 &&
                      (scope.row.status == 5 || scope.row.status == 4)
                    " v-hasPermi="'platformorder/aftersales/refund'" type="text" size="mini"
                    @click="refundHandle(scope.row)">
                    退款
                  </el-button>
                  <el-divider v-if="
                      scope.row.type == 2 &&
                      (scope.row.status == 5 || scope.row.status == 4)
                    " direction="vertical"></el-divider>
                  <el-button @click="detailsDrawerWay(scope.row)" type="text" size="mini">
                    详情
                  </el-button>
                </template>
              </el-table-column>
            </el-table></el-col>
        </el-row>
        <el-row style="text-align: right">
          <pagination v-show="total > 0" :total="total" :page.sync="searchForm.page" :limit.sync="searchForm.count"
            @pagination="getListWay" />
        </el-row>
      </div>
    </div>

    <!-- 审核弹框 -->
    <!-- <el-dialog title="审核" :close-on-click-modal="false" :visible.sync="aftersalesDialog" width="800px"
      @close="aftersalesClose" custom-class="custorm">
      <el-row style="position: relative" v-loading="aftersalesLoading">
        <el-form label-width="110px" :model="aftersalesForm" :rules="aftersalesRules" ref="aftersalesForm">
          <el-col :span="11">
            <el-form-item label="审核状态" prop="status">
              <el-radio-group @change="statusWay" v-model="aftersalesForm.status">
                <el-radio :label="1">同意</el-radio>
                <el-radio :label="2">驳回</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="11" v-if="aftersalesForm.status == 2">
            <el-form-item label="是否锁定订单" prop="is_lock">
              <el-radio-group v-model="aftersalesForm.is_lock">
                <el-radio :label="1">锁定</el-radio>
                <el-radio :label="0">不锁定</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="22" v-if="aftersalesForm.status == 1 && orderInfo.type != 1">
            <el-form-item label="退回渠道" prop="return_type">
              <el-radio-group @change="return_typeChange" v-model="aftersalesForm.return_type">
                <el-radio :label="1">退回给平台</el-radio>
                <el-radio :label="2">退回给原供货商({{
                    orderInfo.supplier ? orderInfo.supplier.supplier_name : "-"
                  }})</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="22" v-if="
              aftersalesForm.status == 1 &&
              orderInfo.type !== 1 &&
              aftersalesForm.return_type == 2
            ">
            <el-form-item label="供货商地址" prop="return_address_id">
              <el-select v-loading="supplierLoading" element-loading-spinner="el-icon-loading" style="width: 100%"
                v-model.trim="aftersalesForm.return_address_id" placeholder="请选择供货商收货地址">
                <el-option v-for="item in supplierAddressList" :key="item.id" :label="
                    item.province_name +
                    item.district_name +
                    item.city_name +
                    item.address_details
                  " :value="item.id">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="22" v-if="
              aftersalesForm.status == 1 &&
              orderInfo.type !== 1 &&
              aftersalesForm.return_type == 1
            ">
            <el-form-item label="平台地址" prop="return_address_id">
              <el-select v-loading="supplierLoading" element-loading-spinner="el-icon-loading" style="width: 100%"
                v-model.trim="aftersalesForm.return_address_id" placeholder="请选择平台收货地址">
                <el-option v-for="item in supplierAddressList" :key="item.id" :label="
                    item.province_name +
                    item.district_name +
                    item.city_name +
                    item.address_details
                  " :value="item.id">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="22">
            <el-form-item label="处理意见">
              <el-input type="textarea" placeholder="请输入处理意见" maxlength="200" show-word-limit clearable
                :autosize="{ minRows: 3, maxRows: 6 }" v-model.trim="aftersalesForm.remark"></el-input>
            </el-form-item>
          </el-col>
        </el-form>
      </el-row>
      <span slot="footer" class="dialog-footer">
        <el-button @click="aftersalesDialog = false">取 消</el-button>
        <el-button type="primary" @click="aftersalesSubmit">确 定</el-button>
      </span>
    </el-dialog> -->

    <!-- 确认收货弹框 -->
    <el-dialog custom-class="custorm" title="确认收货" :close-on-click-modal="false" :visible.sync="confirmDialog"
      width="800px" @close="confirmClose">
      <el-row style="position: relative" v-loading="confirmLoading">
        <el-form label-width="110px" :model="confirmForm" :rules="confirmRules" ref="confirmForm">
          <!-- <el-col :span="22">
            <el-form-item label="收到货物数量" prop="refund_number">
              <el-input
                type="text"
                placeholder="请输入收到货物数量"
                show-word-limit
                clearable
                v-model.trim="confirmForm.refund_number"
              ></el-input>
            </el-form-item>
          </el-col> -->
          <el-col :span="22">
            <el-form-item label="货物图片">
              <logo-upload :file-list="imgs" :show-file-list="true" accept="image/jpeg, image/png"
                @uploadCallback="imgsCallback" />
            </el-form-item>
          </el-col>
          <el-col :span="22">
            <el-form-item label="备注">
              <el-input type="textarea" placeholder="请输入备注" maxlength="200" show-word-limit clearable
                :autosize="{ minRows: 3, maxRows: 6 }" v-model.trim="confirmForm.remark"></el-input>
            </el-form-item>
          </el-col>
        </el-form>
      </el-row>
      <span slot="footer" class="dialog-footer">
        <el-button @click="confirmDialog = false">取 消</el-button>
        <el-button type="primary" @click="confirmSubmit">确 定</el-button>
      </span>
    </el-dialog>

    <!-- 确认换货弹框 -->
    <el-dialog custom-class="custorm" title="确认换货" :close-on-click-modal="false" :visible.sync="exchangeDialog"
      width="800px" @close="exchangeClose">
      <el-row style="position: relative" v-loading="exchangeLoading">
        <el-form label-width="110px" :model="exchangeForm" :rules="exchangeRules" ref="exchangeForm">
          <!-- <el-col :span="11">
            <el-form-item label="商品" prop="goodsId">
              <el-select
                v-model="goodsId"
                filterable
                remote
                reserve-keyword
                @change="exchangeGoodsWay"
                placeholder="根据商品名、ID、编码查询"
                :remote-method="remoteMethod"
                :loading="exchangeSelectloading"
              >
                <el-option
                  v-for="item in GoodsList"
                  :key="item.id"
                  :label="item.name"
                  :value="item.product"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col> -->
          <el-col :span="11">
            <el-form-item label="商品数量" prop="buy_number">
              <el-input type="text" placeholder="请输入商品数量" show-word-limit clearable
                v-model.trim="exchangeForm.buy_number"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="22">
            <el-form-item label="备注">
              <el-input type="textarea" placeholder="请输入备注" maxlength="200" show-word-limit clearable
                :autosize="{ minRows: 3, maxRows: 6 }" v-model.trim="exchangeForm.remark"></el-input>
            </el-form-item>
          </el-col>
        </el-form>
      </el-row>
      <span slot="footer" class="dialog-footer">
        <el-button @click="exchangeDialog = false">取 消</el-button>
        <el-button type="primary" :loading="aftersalesLoading" @click="exchangeSubmit">确 定</el-button>
      </span>
    </el-dialog>

    <!-- 退款弹框弹框 -->
    <el-dialog custom-class="custorm" title="退款信息" :close-on-click-modal="false" :visible.sync="refundDialog"
      width="700px" @close="refundclose">
      <el-row style="position: relative" v-loading="refundLoading">
        <el-form label-width="100px" :model="refundform" :rules="refundRules" ref="refundform">
          <el-col :span="11">
            <el-form-item label="退款提货券" prop="coupon_total">
              <el-input type="Number" min="0" placeholder="请输入退款提货券" show-word-limit
                v-model.trim="refundform.coupon_total"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="22">
            <el-form-item label="备注">
              <el-input type="textarea" placeholder="请输入备注" maxlength="200" show-word-limit
                :autosize="{ minRows: 3, maxRows: 6 }" v-model.trim="refundform.remark"></el-input>
            </el-form-item>
          </el-col>
        </el-form>
      </el-row>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" :loading="refundLoading" @click="refundSubmit">确 定</el-button>
      </span>
    </el-dialog>

    <el-dialog custom-class="custorm" title="协商记录" :close-on-click-modal="false" :append-to-body="true"
      :visible.sync="recordDialog" width="500px">
      <el-row :gutter="20" style="position: relative" v-loading="recordLoading">
        <el-col :span="22" v-if="recordList.length !== 0">
          <el-timeline>
            <el-timeline-item v-for="(item, index) in recordList" :key="index" :timestamp="item.created_at"
              placement="top">
              <el-card>
                <el-descriptions :column="2">
                  <el-descriptions-item label="处理来源">
                    <el-tag size="mini" v-if="item.from_type == 1">平台</el-tag>
                    <el-tag size="mini" v-if="item.from_type == 2">供货商</el-tag>
                    <el-tag size="mini" v-if="item.from_type == 3">用户</el-tag>
                  </el-descriptions-item>
                  <el-descriptions-item label="日志类别">
                    <el-tag size="mini" v-if="item.from_type == 1">普通日志</el-tag>
                    <el-tag size="mini" v-if="item.from_type == 2">退回地址记录</el-tag>
                    <el-tag size="mini" v-if="item.from_type == 3">商品寄回日志</el-tag>
                    <el-tag size="mini" v-if="item.from_type == 4">商品发货日志</el-tag>
                  </el-descriptions-item>
                  <el-descriptions-item label="备注" :span="2">
                    {{ item.remark }}
                  </el-descriptions-item>

                  <el-descriptions-item label="图片" v-if="item.imgs.length !== 0">
                    <div v-for="(items, indexs) in item.imgs" :key="indexs"
                      style="width: 30px; height: 30px; margin: 5px">
                      <el-image v-if="items" :src="items" :preview-src-list="[items]" />
                    </div>
                  </el-descriptions-item>
                </el-descriptions>
              </el-card>
            </el-timeline-item>
          </el-timeline>
        </el-col>
        <el-empty v-else description="暂无记录"></el-empty>
      </el-row>
      <span slot="footer" class="dialog-footer">
        <el-button :loading="recordLoading" type="primary" @click="recordDialog = false">关闭</el-button>
      </span>
    </el-dialog>

    <el-drawer :modal-append-to-body="false" :append-to-body="true" title="订单信息" size="70%" :withHeader="false"
      :visible.sync="detailsDrawer" @close="addressClose" :show-close="true">
      <div style="position: relative" v-loading="detailsLoading">
        <div class="drawerTitle">
          <span>订单信息</span>
          <div class="close" @click="addressClose">
            <i class="el-icon-close" style="font-size: 24px;"></i>
          </div>
        </div>
        <div class="drawerContent">
          <div class="infoView">
            <div class="status">
              <span>售后单号：</span>
              <span v-if="detailsInfo.refund">{{detailsInfo.refund.refund_order_no}}</span>
            </div>
            <el-descriptions style="width: 50%;" :column="2">
              <el-descriptions-item labelClassName="descriptionsLabel" content-class-name="descriptionsLabel"
                label="商户名称">
                {{ detailsInfo.merchant ? detailsInfo.merchant.mer_name : "-" }}
              </el-descriptions-item>
              <el-descriptions-item labelClassName="descriptionsLabel" content-class-name="descriptionsLabel"
                label="联系人">
                {{
                  detailsInfo.merchant ? detailsInfo.merchant.user_name : "-"
                }}
              </el-descriptions-item>

              <el-descriptions-item labelClassName="descriptionsLabel" content-class-name="descriptionsLabel"
                label="认证状态">
                <div style="color: #0076f6;" v-if="
                    detailsInfo.merchant
                      ? detailsInfo.merchant.auth_status == 1
                      : false
                  ">已认证</div>
                <div style="color: #ff4949;" v-if="
                    detailsInfo.merchant
                      ? detailsInfo.merchant.auth_status == 0
                      : false
                  ">未认证</div>
              </el-descriptions-item>
              <el-descriptions-item labelClassName="descriptionsLabel" content-class-name="descriptionsLabel"
                label="联系电话">
                {{
                  detailsInfo.merchant
                    ? detailsInfo.merchant.user_cellphone
                    : "-"
                }}
              </el-descriptions-item>
            </el-descriptions>
          </div>
          <div class="informationTitleView">
            <div class="leftBox">
              <div class="leftborder"></div>
              <div class="text">售后信息</div>
            </div>
            <div class="right"></div>
          </div>
          <div style="padding: 0 10px">
            <el-descriptions :column="2">
              <el-descriptions-item labelClassName="descriptionsLabel" content-class-name="descriptionsLabel"
                label="售后单号">
                {{
                  detailsInfo.refund ? detailsInfo.refund.refund_order_no : "-"
                }}
              </el-descriptions-item>
              <el-descriptions-item labelClassName="descriptionsLabel" content-class-name="descriptionsLabel"
                label="申请时间">
                {{ detailsInfo.refund ? detailsInfo.refund.created_at : "-" }}
              </el-descriptions-item>
              <el-descriptions-item labelClassName="descriptionsLabel" content-class-name="descriptionsLabel"
                label="售后状态">
                <div v-if="
                    detailsInfo.refund
                      ? detailsInfo.refund.refund_status == 1
                      : false
                  " size="mini">待审核</div>
                <div v-if="
                    detailsInfo.refund
                      ? detailsInfo.refund.refund_status == 8
                      : false
                  " size="mini">售后完成（已退换货完成）</div>
                <div v-if="
                    detailsInfo.refund
                      ? detailsInfo.refund.refund_status == 9
                      : false
                  " size="mini">售后审核拒绝</div>
                <div v-if="
                    detailsInfo.refund
                      ? detailsInfo.refund.refund_status == 10
                      : false
                  " size="mini">已取消申请</div>
              </el-descriptions-item>
              <el-descriptions-item labelClassName="descriptionsLabel" content-class-name="descriptionsLabel"
                label="退单数量">
                {{
                  detailsInfo.refund ? detailsInfo.refund.refund_number : "-"
                }}
              </el-descriptions-item>
              <el-descriptions-item labelClassName="descriptionsLabel" content-class-name="descriptionsLabel"
                label="退单总额">
                {{ detailsInfo.refund ? detailsInfo.refund.coupon_total : "-" }}
              </el-descriptions-item>
              <el-descriptions-item labelClassName="descriptionsLabel" content-class-name="descriptionsLabel"
                label="申请说明">
                {{
                  detailsInfo.refund
                    ? detailsInfo.refund.supplementary_info
                    : "-"
                }}
              </el-descriptions-item>
              <el-descriptions-item labelClassName="descriptionsLabel" content-class-name="descriptionsLabel"
                label="售后原因">
                {{ detailsInfo.refund ? detailsInfo.refund.remark : "-" }}
              </el-descriptions-item>
              <el-descriptions-item labelClassName="descriptionsLabel" content-class-name="descriptionsLabel"
                label="审核备注">
                {{ detailsInfo.refund ? detailsInfo.refund.admin_remark : "-" }}
              </el-descriptions-item>
              <el-descriptions-item labelClassName="descriptionsLabel" content-class-name="descriptionsLabel"
                label="审核员姓名">
                {{
                  detailsInfo.refund ? detailsInfo.refund.admin_username : "-"
                }}
              </el-descriptions-item>
              <el-descriptions-item labelClassName="descriptionsLabel" content-class-name="descriptionsLabel"
                label="审核时间">
                {{ detailsInfo.refund ? detailsInfo.refund.audit_time : "-" }}
              </el-descriptions-item>
            </el-descriptions>
          </div>
          <div class="informationTitleView">
            <div class="leftBox">
              <div class="leftborder"></div>
              <div class="text">订单信息</div>
            </div>
            <div class="right"></div>
          </div>
          <div style="padding: 0 10px">
            <el-descriptions :column="2">
              <el-descriptions-item labelClassName="descriptionsLabel" content-class-name="descriptionsLabel"
                label="订单编号">
                {{ detailsInfo.order ? detailsInfo.order.mer_order_no : "-" }}
              </el-descriptions-item>
              <el-descriptions-item labelClassName="descriptionsLabel" content-class-name="descriptionsLabel"
                label="下单时间">
                {{ detailsInfo.order ? detailsInfo.order.created_at : "-" }}
              </el-descriptions-item>
              <el-descriptions-item labelClassName="descriptionsLabel" content-class-name="descriptionsLabel"
                label="购买数量">
                {{ detailsInfo.order ? detailsInfo.order.product_num : "-" }}
              </el-descriptions-item>
              <el-descriptions-item labelClassName="descriptionsLabel" content-class-name="descriptionsLabel"
                label="提货券单价">
                {{ detailsInfo.order ? detailsInfo.order.coupon_unit : "-" }}
              </el-descriptions-item>
              <el-descriptions-item labelClassName="descriptionsLabel" content-class-name="descriptionsLabel"
                label="提货券总价">
                {{ detailsInfo.order ? detailsInfo.order.coupon_total : "-" }}
              </el-descriptions-item>
              <el-descriptions-item labelClassName="descriptionsLabel" content-class-name="descriptionsLabel"
                label="支付时间">
                {{ detailsInfo.order ? detailsInfo.order.pay_time : "-" }}
              </el-descriptions-item>
            </el-descriptions>
          </div>
          <div class="informationTitleView">
            <div class="leftBox">
              <div class="leftborder"></div>
              <div class="text">供货商信息</div>
            </div>
            <div class="right"></div>
          </div>
          <div style="padding: 0 10px">
            <el-descriptions :column="2">
              <el-descriptions-item labelClassName="descriptionsLabel" content-class-name="descriptionsLabel"
                label="供货商名称">
                {{
                  detailsInfo.supplier
                    ? detailsInfo.supplier.supplier_name
                    : "-"
                }}
              </el-descriptions-item>
              <el-descriptions-item labelClassName="descriptionsLabel" content-class-name="descriptionsLabel"
                label="供货商ID">
                {{
                  detailsInfo.supplier ? detailsInfo.supplier.supplier_id : "-"
                }}
              </el-descriptions-item>
            </el-descriptions>
          </div>
          <el-row>
            <el-col style="text-align: right">
              <el-button v-if="
                  detailsInfo.refund
                    ? detailsInfo.refund.refund_status == 1
                    : false
                " v-hasPermi="'platformorder/aftersales/auditing'" style="margin: 5px" type="primary" size="mini"
                @click="drawerHandle(detailsInfo)">
                审核处理
              </el-button>
            </el-col>
          </el-row>
        </div>
      </div>
    </el-drawer>
    <!-- 审核 -->
    <el-drawer :modal-append-to-body="false" :append-to-body="true" title="审核信息" size="60%" :withHeader="false"
      :visible.sync="aftersalesDialog" @close="aftersalesClose" :show-close="true">
      <div class="drawerTitle">
        <span>审核信息</span>
        <div class="close" @click="aftersalesClose">
          <i class="el-icon-close" style="font-size: 24px;"></i>
        </div>
      </div>
      <el-scrollbar
        wrap-style="overflow-x:hidden;"
        style="height: calc(100vh - 150px)"
      >
      <div class="drawerContent">
        <el-row style="position: relative" v-loading="aftersalesLoading">
          <el-form label-width="110px" :model="aftersalesForm" :rules="aftersalesRules" ref="aftersalesForm">
            <el-col :span="11">
              <el-form-item label="审核状态" prop="status">
                <el-radio-group @change="statusWay" v-model="aftersalesForm.status">
                  <el-radio :label="1">同意</el-radio>
                  <el-radio :label="2">驳回</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-col>
            <el-col :span="11" v-if="aftersalesForm.status == 2">
              <el-form-item label="是否锁定订单" prop="is_lock">
                <el-radio-group v-model="aftersalesForm.is_lock">
                  <el-radio :label="1">锁定</el-radio>
                  <el-radio :label="0">不锁定</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-col>
            <el-col :span="22" v-if="aftersalesForm.status == 1 && orderInfo.type != 1">
              <el-form-item label="退回渠道" prop="return_type">
                <el-radio-group @change="return_typeChange" v-model="aftersalesForm.return_type">
                  <el-radio :label="1">退回给平台</el-radio>
                  <el-radio :label="2">退回给原供货商({{
                      orderInfo.supplier ? orderInfo.supplier.supplier_name : "-"
                    }})</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-col>
            <el-col :span="22" v-if="
                aftersalesForm.status == 1 &&
                orderInfo.type !== 1 &&
                aftersalesForm.return_type == 2
              ">
              <el-form-item label="供货商地址" prop="return_address_id">
                <el-select v-loading="supplierLoading" element-loading-spinner="el-icon-loading" style="width: 100%"
                  v-model.trim="aftersalesForm.return_address_id" placeholder="请选择供货商收货地址">
                  <el-option v-for="item in supplierAddressList" :key="item.id" :label="
                      item.province_name +
                      item.district_name +
                      item.city_name +
                      item.address_details
                    " :value="item.id">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="22" v-if="
                aftersalesForm.status == 1 &&
                orderInfo.type !== 1 &&
                aftersalesForm.return_type == 1
              ">
              <el-form-item label="平台地址" prop="return_address_id">
                <el-select v-loading="supplierLoading" element-loading-spinner="el-icon-loading" style="width: 100%"
                  v-model.trim="aftersalesForm.return_address_id" placeholder="请选择平台收货地址">
                  <el-option v-for="item in supplierAddressList" :key="item.id" :label="
                      item.province_name +
                      item.district_name +
                      item.city_name +
                      item.address_details
                    " :value="item.id">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="22">
              <el-form-item label="处理意见">
                <el-input type="textarea" placeholder="请输入处理意见" maxlength="200" show-word-limit clearable
                  :autosize="{ minRows: 3, maxRows: 6 }" v-model.trim="aftersalesForm.remark"></el-input>
              </el-form-item>
            </el-col>
          </el-form>
        </el-row>
      </div>
      </el-scrollbar>
      <el-col :span="24" style="text-align: right; padding-right: 30px;">
            <el-button @click="aftersalesDialog = false">取 消</el-button>
            <el-button type="primary" @click="aftersalesSubmit">确 定</el-button>
          </el-col>
    </el-drawer>
  </div>
</template>

<script>
  import {
    getSelfList,
    getSelfVerify,
    getSelfConfirmReturn,
    refundAddRefundNewOrder,
    selfConfirmRefundBack,
    getRefundHistoryList,
    getSelfDetail,
  } from "@/api/order/index";
  import {
    getGoodsList,
    getPublicSupplierAddressList,
    getShippingAddress,
  } from "@/api/index";
  import LogoUpload from "@/components/FileUpload";
  const tableTheadOption = {

    mer_order_no: {
      label: "自提订单号",
      field: "mer_order_no",
      width: 200,
    },
    refund_order_no: {
      label: "售后订单号",
      field: "refund_order_no",
      width: 200,
    },
    mer_id: {
      label: "商户ID",
      field: "mer_id",
    },
    mer_name: {
      label: "商户名称",
      field: "mer_name",
      width: 100,
    },
    product_name: {
      label: "商品名称",
      field: "product_name",
      width: 160,
    },
    sku_img: {
      label: "规格图片",
      field: "sku_img",
    },
    sku_name: {
      label: "规格名称",
      field: "sku_name",
    },
    coupon_unit: {
      label: "提货券单价",
      field: "coupon_unit",
    },
    created_at: {
      label: "申请时间",
      field: "created_at",
      width: 140,
    },
    refund_number: {
      label: "退货数量",
      field: "refund_number",
    },
    coupon_total: {
      label: "退款提货券",
      field: "coupon_total",
    },
    type: {
      label: "售后类型",
      field: "type",
    },
  };
  const allTableThead = [

    "mer_order_no",
    "refund_order_no",
    "mer_id",
    "mer_name",
    "product_name",
    "sku_img",
    "sku_name",
    "created_at",
    "coupon_unit",
    "refund_number",
    "coupon_total",
    "type",
    // "status",
  ];
  const defaultTableThead = [

    "mer_order_no",
    "refund_order_no",
    "mer_name",
    "product_name",
    // "sku_img",
    // "sku_name",
    "created_at",
    // "coupon_unit",
    // "refund_number",
    "coupon_total",
    "type",
  ];
  export default {
    components: {
      LogoUpload
    },
    watch: {
      checkboxTableThead(valArr) {
        this.tableThead = this.allTableThead.filter(
          (i) => valArr.indexOf(i) >= 0
        );
        this.tableKey = this.tableKey + 1;
        this.$nextTick(() => {
          this.$refs.tablerefs.doLayout();
        });
      },
    },
    data() {
      return {
        // 默认表头
        tableTheadOptions: tableTheadOption,
        allTableThead: allTableThead,
        tableThead: defaultTableThead, // 默认表头
        checkboxTableThead: defaultTableThead, // 默认表头值
        tableKey: 1, // 为了保证table 每次都会重渲
        loading: false,
        searchDisplay: false,
        searchForm: {
          status: "", // 售后状态检索：0=发起申请；1=处理中；2=处理完成；3=审核未通过；4=取消申请
          refund_order_no: "", // 根据退款订单号筛选
          order_trade_no: "", // 根据订单流水号检索
          pay_order_no: "", // 根据订单支付单号检索
          pay_service: "", // 根据支付方式检索：1=余额支付；2=支付宝；3=微信
          user_id: "", // 根据用户ID筛选
          phone_number: "", // 收货人电话检索
          recipient: "", // 收货人姓名检索
          goods_id: "", // 商品ID检索
          goods_name: "", // 商品名称检索
          supplier_id: "", // 供货商ID检索
          mer_id: "", // 店铺/商户ID检索（0=平台自营）
          create_time_start: "", // 申请起始时间（例：2023-10-01 12:20）
          create_time_end: "", // 	申请截至时间（例：2023-10-02 12:20）
          verify_time_start: "", // 审核起始时间（例：2023-10-01 12:20）
          verify_time_end: "", // 审核截至时间（例：2023-10-02 12:20）
          complete_time_start: "", // 退款完成起始时间（例：2023-10-01 12:20）
          complete_time_end: "", // 退款完成截至时间（例：2023-10-02 12:20）
          pay_time_start: "", // 支付起始时间
          pay_time_end: "", // 支付截至时间
          count: 20,
          page: 1,
        },
        create_time: [],
        verify_time: [],
        complete_time: [],
        pay_time: [],
        pickerOptions: {
          shortcuts: [{
              text: "最近一周",
              onClick(picker) {
                const end = new Date();
                const start = new Date();
                start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
                picker.$emit("pick", [start, end]);
              },
            },
            {
              text: "最近一个月",
              onClick(picker) {
                const end = new Date();
                const start = new Date();
                start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
                picker.$emit("pick", [start, end]);
              },
            },
            {
              text: "最近三个月",
              onClick(picker) {
                const end = new Date();
                const start = new Date();
                start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
                picker.$emit("pick", [start, end]);
              },
            },
          ],
        },
        RefundList: [],
        total: 0,
        aftersalesDialog: false,
        aftersalesLoading: false,
        aftersalesForm: {
          refund_id: "", // 售后订单ID
          status: 1, // 平台处理状态：1=同意售后申请；2=拒绝售后申请
          remark: "", // 处理备注/意见
          is_lock: "", // （拒绝售后申请）是否锁定订单：1=锁定；0=不锁定
          return_type: 2, // （同意售后申请 - 退换货必填）用户退回的对象：1=退回给平台，2=退回给原供货商
          return_address_id: "", // （同意售后申请 - 退换货必填）用户退回的地址【若是平台，选择平台的地址；若是供货商，选择供货商的退回地址】
        },

        orderInfo: {}, // 当亲操作的订单信息
        aftersalesRules: {
          status: [{
            required: true,
            validator: (rule, value, callback) => {
              if (value === "") {
                callback(new Error("请选择审核状态"));
              } else {
                callback();
              }
            },
            trigger: "change",
          }, ],
          is_lock: [{
            required: true,
            validator: (rule, value, callback) => {
              if (this.aftersalesForm.status == 2) {
                if (value === "") {
                  callback(new Error("请选择是否锁定订单"));
                } else {
                  callback();
                }
              } else {
                callback();
              }
            },
            trigger: "change",
          }, ],
          return_type: [{
            required: true,
            validator: (rule, value, callback) => {
              if (this.aftersalesForm.status == 1 && this.orderInfo.type != 1) {
                if (value === "") {
                  callback(new Error("请选择退回渠道"));
                } else {
                  callback();
                }
              } else {
                callback();
              }
            },
            trigger: "change",
          }, ],
          return_address_id: [{
            required: true,
            validator: (rule, value, callback) => {
              if (
                this.aftersalesForm.status == 1 &&
                this.orderInfo.type !== 1
              ) {
                if (value === "") {
                  callback(new Error("请选择退回渠道地址"));
                } else {
                  callback();
                }
              } else {
                callback();
              }
            },
            trigger: "change",
          }, ],
        },
        confirmDialog: false,
        confirmLoading: false,
        confirmForm: {
          refund_id: "",
          refund_number: "",
          remark: "",
          imgs: "",
        },
        imgs: [],
        confirmRules: {
          refund_number: [{
            required: true,
            validator: (rule, value, callback) => {
              const req = /\D/g;
              if (value === "") {
                callback(new Error("请输入收到货物数量"));
              } else {
                if (req.test(value)) {
                  callback(new Error("请输入整数"));
                }
                callback();
              }
            },
            trigger: "change",
          }, ],
        },
        exchangeDialog: false,
        exchangeLoading: false,
        exchangeSelectloading: false,
        GoodsList: [],
        exchangeForm: {
          refund_id: "",
          product_id: "",
          buy_number: "",
          remark: "",
        },
        goodsId: "",
        exchangeRules: {
          goodsId: [{
            required: true,
            validator: (rule, value, callback) => {
              if (value === "") {
                callback(new Error("请选择商品"));
              } else {
                callback();
              }
            },
            trigger: "change",
          }, ],
          buy_number: [{
            required: true,
            validator: (rule, value, callback) => {
              const req = /\D/g;
              if (value === "") {
                callback(new Error("请输入收到货物数量"));
              } else {
                if (req.test(value)) {
                  callback(new Error("请输入整数"));
                }
                callback();
              }
            },
            trigger: "change",
          }, ],
        },
        refundDialog: false,
        refundLoading: false,
        refundform: {
          refund_id: "",
          refund_number: "",
          price_total: "",
          points_total: "",
          coupon_total: "",
          remark: "",
        },
        refundRules: {
          refund_number: [{
            required: false,
            validator: (rule, value, callback) => {
              const req = /\D/g;
              if (value === "") {
                callback(new Error("请输入退单数量"));
              } else {
                if (req.test(value)) {
                  callback(new Error("请输入整数"));
                }
                callback();
              }
            },
            trigger: "change",
          }, ],
          price_total: [{
            required: false,
            validator: (rule, value, callback) => {
              let req = /^\d+(\.\d{1,2})?$/;
              if (value === "" || value == 0) {
                callback();
              } else {
                if (req.test(value)) {
                  callback();
                } else {
                  callback(new Error("最多只能保留两位小数"));
                }
              }
            },
            trigger: "change",
          }, ],
          points_total: [{
            required: false,
            validator: (rule, value, callback) => {
              let req = /^\d+(\.\d{1,2})?$/;
              if (value === "" || value == 0) {
                callback();
              } else {
                if (req.test(value)) {
                  callback();
                } else {
                  callback(new Error("最多只能保留两位小数"));
                }
              }
            },
            trigger: "change",
          }, ],
          coupon_total: [{
            required: false,
            validator: (rule, value, callback) => {
              let req = /^\d+(\.\d{1,2})?$/;
              if (value === "" || value == 0) {
                callback();
              } else {
                if (req.test(value)) {
                  callback();
                } else {
                  callback(new Error("最多只能保留两位小数"));
                }
              }
            },
            trigger: "change",
          }, ],
        },
        recordLoading: false,
        recordDialog: false,
        recordList: [],

        detailsDrawer: false,
        detailsLoading: false,
        detailsInfo: {},

        supplierAddressList: [], // 供货商地址
        supplierLoading: false,
        ShippingAddressList: [], // 平台地址
      };
    },
    created() {
      this.getListWay();
    },
    methods: {
      addressClose() {
        this.detailsDrawer = false;
      },
      getListWay() {
        this.loading = true;
        getSelfList(this.searchForm)
          .then((res) => {
            this.loading = false;
            this.RefundList = res.data.list;
            this.total = res.data.total;
          })
          .catch((err) => {
            this.loading = false;
            this.$messages.error(err.msg);
          });
      },
      resetting() {
        this.searchForm = {
          status: "", // 售后状态检索：0=发起申请；1=处理中；2=处理完成；3=审核未通过；4=取消申请
          refund_order_no: "", // 根据退款订单号筛选
          order_trade_no: "", // 根据订单流水号检索
          pay_order_no: "", // 根据订单支付单号检索
          pay_service: "", // 根据支付方式检索：1=余额支付；2=支付宝；3=微信
          user_id: "", // 根据用户ID筛选
          phone_number: "", // 收货人电话检索
          recipient: "", // 收货人姓名检索
          goods_id: "", // 商品ID检索
          goods_name: "", // 商品名称检索
          supplier_id: "", // 供货商ID检索
          mer_id: "", // 店铺/商户ID检索（0=平台自营）
          create_time_start: "", // 申请起始时间（例：2023-10-01 12:20）
          create_time_end: "", // 	申请截至时间（例：2023-10-02 12:20）
          verify_time_start: "", // 审核起始时间（例：2023-10-01 12:20）
          verify_time_end: "", // 审核截至时间（例：2023-10-02 12:20）
          complete_time_start: "", // 退款完成起始时间（例：2023-10-01 12:20）
          complete_time_end: "", // 退款完成截至时间（例：2023-10-02 12:20）
          pay_time_start: "", // 支付起始时间
          pay_time_end: "", // 支付截至时间
          count: 20,
          page: 1,
        };
        this.create_time = [];
        this.pay_time = [];
        this.getListWay();
      },
      create_timeWay(vla) {
        this.searchForm.create_time_start = vla[0];
        this.searchForm.create_time_end = vla[1];
      },
      complete_timeWay(vla) {
        this.searchForm.complete_time_start = vla[0];
        this.searchForm.complete_time_end = vla[1];
      },
      verify_timeWay(vla) {
        this.searchForm.verify_time_start = vla[0];
        this.searchForm.verify_time_end = vla[1];
      },
      pay_timeWay(vla) {
        this.searchForm.pay_time_start = vla[0];
        this.searchForm.pay_time_end = vla[1];
      },
      drawerHandle(row) {
        this.aftersalesDialog = true;
        this.aftersalesLoading = true;
        getSelfDetail({
          id: row.id
        }).then((res) => {
          this.orderInfo = res.data;
          this.orderInfo.id = row.id;
          this.aftersalesForm.refund_id = this.orderInfo.id;
          if (this.orderInfo.type == 1) {
            this.aftersalesForm.return_type = "";
          }
          this.return_typeChange(2);

          this.aftersalesLoading = false;
        });
      },
      statusWay(val) {
        if (val == 2) {
          this.aftersalesForm.is_lock = 0;
        } else {
          this.aftersalesForm.is_lock = "";
        }
      },
      detailsDrawerWay(row) {
        this.detailsDrawer = true;
        this.detailsLoading = true;
        getSelfDetail({
          id: row.id
        }).then((res) => {
          this.detailsInfo = JSON.parse(JSON.stringify(res.data));
          this.detailsInfo.id = row.id;
          this.detailsLoading = false;
        });
      },
      aftersalesClose() {
        this.aftersalesForm = {
          refund_id: "", // 售后订单ID
          status: 1, // 平台处理状态：1=同意售后申请；2=拒绝售后申请
          remark: "", // 处理备注/意见
          is_lock: "", // （拒绝售后申请）是否锁定订单：1=锁定；0=不锁定
          return_type: 2, // （同意售后申请 - 退换货必填）用户退回的对象：1=退回给平台，2=退回给原供货商
          return_address_id: "", // （同意售后申请 - 退换货必填）用户退回的地址【若是平台，选择平台的地址；若是供货商，选择供货商的退回地址】
        };
        this.aftersalesDialog = false;
      },
      return_typeChange(val) {
        this.aftersalesForm.return_address_id = "";
        if (val == 1) {
          this.supplierRemoteMethods();
        } else {
          this.supplierRemoteMethod(this.orderInfo.supplier.supplier_id);
        }
      },
      supplierRemoteMethod(query) {
        this.supplierLoading = true;
        getPublicSupplierAddressList({
          supplier_id: query
        }).then((res) => {
          if (res.code !== 200 || res.status !== 1) {
            this.supplierLoading = false;
            return this.$messages.error(res.msg);
          }
          if (res.data.list.length !== 0) {
            res.data.list.forEach((item) => {
              if (item.is_default == 1) {
                this.aftersalesForm.return_address_id = item.id;
              }
            });
            this.supplierAddressList = res.data.list;

            if (!this.aftersalesForm.return_address_id) {
              this.aftersalesForm.return_address_id =
                this.supplierAddressList[0].id;
            }
          }

          this.supplierLoading = false;
        });
      },
      supplierRemoteMethods() {
        this.supplierLoading = true;
        getShippingAddress().then((res) => {
          if (res.code !== 200 || res.status !== 1) {
            this.supplierLoading = false;
            return this.$messages.error(res.msg);
          }
          res.data.list.forEach((item) => {
            if (item.is_default == 1) {
              this.aftersalesForm.return_address_id =
                item.province_name +
                item.district_name +
                item.city_name +
                item.address_details;
            }
          });
          this.supplierAddressList = res.data.list;
          if (!this.aftersalesForm.return_address_id) {
            this.aftersalesForm.return_address_id =
              res.data.list[0].province_name +
              res.data.list[0].district_name +
              res.data.list[0].city_name +
              res.data.list[0].address_details;
          }
          this.supplierLoading = false;
        });
      },
      aftersalesSubmit() {
        this.$refs.aftersalesForm.validate((valid) => {
          if (valid) {
            this.aftersalesLoading = true;
            this.aftersalesForm.id = this.aftersalesForm.refund_id;
            getSelfVerify(this.aftersalesForm).then((res) => {
              if (res.code !== 200 || res.status !== 1) {
                this.aftersalesLoading = false;
                return this.$messages.error(res.msg);
              }
              this.$messages.success(res.msg);
              this.aftersalesLoading = false;
              this.aftersalesDialog = false;
              this.getListWay();
            });
          } else {
            return false;
          }
        });
      },

      confirmClose() {
        this.confirmForm = {
          refund_id: "",
          refund_number: "",
          remark: "",
          imgs: "",
        };
        this.imgs = [];
      },
      imgsCallback(file) {
        this.imgs = file;
      },
      confirmHandle(row) {
        this.confirmForm.refund_id = row.id;
        this.confirmForm.refund_number = row.refund_number;
        this.confirmDialog = true;
      },
      confirmSubmit() {
        this.$refs.confirmForm.validate((valid) => {
          if (valid) {
            this.confirmLoading = true;
            var arr = [];
            this.imgs.forEach((item) => {
              arr.push(item.url);
            });
            this.confirmForm.imgs = arr.toString();
            var obj = {
              id: this.confirmForm.refund_id,
              remark: this.confirmForm.remark,
              info: this.confirmForm.imgs,
            };
            getSelfConfirmReturn(obj).then((res) => {
              if (res.code !== 200 || res.status !== 1) {
                this.confirmLoading = false;
                return this.$messages.error(res.msg);
              }
              this.$messages.success(res.msg);
              this.confirmLoading = false;
              this.confirmDialog = false;
              this.getListWay();
            });
          } else {
            return false;
          }
        });
      },
      exchangeHandle(row) {
        this.exchangeDialog = true;
        this.exchangeLoading = true;
        this.exchangeForm.refund_id = row.id;
        getGoodsList({
          count: 20,
          page: 1
        }).then((res) => {
          if (res.code !== 200 || res.status !== 1) {
            this.GoodsList = [];
            this.exchangeLoading = false;
            return this.$messages.error(res.msg);
          }
          this.exchangeLoading = false;
          this.GoodsList = res.data.list;
        });
      },
      exchangeClose() {
        this.exchangeForm = {
          refund_id: "",
          product_id: "",
          buy_number: "",
          remark: "",
        };
        this.exchangeDialog = false;
      },
      remoteMethod(query) {
        this.exchangeSelectloading = true;
        getGoodsList({
          count: 20,
          page: 1,
          keywords: query
        }).then((res) => {
          if (res.code !== 200 || res.status !== 1) {
            this.aftersalesLoading = false;
            this.GoodsList = [];
            return this.$messages.error(res.msg);
          }
          this.GoodsList = res.data.list;
        });
      },
      exchangeGoodsWay(val) {
        this.exchangeForm.product_id = val[0].id;
      },
      exchangeSubmit() {
        this.$refs.exchangeForm.validate((valid) => {
          if (valid) {
            this.aftersalesLoading = true;
            var obj = {
              id: this.exchangeForm.refund_id,
              buy_number: this.exchangeForm.buy_number,
              remark: this.exchangeForm.remark,
            };
            refundAddRefundNewOrder(obj).then((res) => {
              if (res.code !== 200 || res.status !== 1) {
                this.aftersalesLoading = false;
                return this.$messages.error(res.msg);
              }
              this.$messages.success(res.msg);
              this.aftersalesLoading = false;
              this.exchangeDialog = false;
              this.getListWay();
            });
          }
        });
      },
      refundHandle(row) {
        this.refundform.refund_id = row.id;
        // this.refundform.refund_number = row.refund_number;
        // this.refundform.price_total = row.product_retail_price;
        // this.refundform.points_total = row.points_total;
        this.refundform.coupon_total = row.coupon_total;
        this.refundDialog = true;
      },
      refundclose() {},
      refundSubmit() {
        this.$refs.refundform.validate((valid) => {
          if (valid) {
            this.refundLoading = true;
            var obj = {
              id: this.refundform.refund_id,
              coupon_total: this.refundform.coupon_total,
              remark: this.refundform.remark,
            };
            selfConfirmRefundBack(obj).then((res) => {
              if (res.code !== 200 || res.status !== 1) {
                this.refundLoading = false;
                return this.$messages.error(res.msg);
              }
              this.$messages.success(res.msg);
              this.refundDialog = false;
              this.refundform = {
                detail_id: "",
                price_total: "",
                points_total: "",
                coupon_total: "",
                reason: "",
              };
              this.getListWay();
            });
          } else {
            return false;
          }
        });
      },
      recordDialogWay(row) {
        console.log(row);
        this.recordDialog = true;
        this.recordLoading = true;
        getRefundHistoryList({
          refund_id: row.refund_id
        }).then((res) => {
          if (res.code !== 200 || res.status !== 1) {
            this.recordLoading = false;
            return this.$messages.error(res.msg);
          }
          this.recordLoading = false;
          this.recordList = res.data;
        });
      },
    },
  };
</script>

<style>
  #addgoods .el-upload--picture-card {
    width: 90px !important;
    height: 90px !important;
    line-height: 90px;
  }

  #addgoods .el-upload-list--picture-card .el-upload-list__item-actions {
    width: 90px !important;
    height: 90px !important;
  }

  #addgoods .el-upload-list--picture-card .el-upload-list__item-thumbnail {
    width: 90px !important;
    height: 90px !important;
  }

  #addgoods .el-upload-list--picture-card .el-upload-list__item {
    width: 90px !important;
    height: 90px !important;
  }
</style>
<style lang="scss">
  .el-divider--horizontal {
    margin: 10px 0 !important;
  }

  .search-form-item {
    padding-bottom: 10px;
    padding-right: 20px;

    .el-form-item__label {
      font-size: 12px;
      font-weight: 500;
      // width:96px;
    }

    .el-input {
      width: 180px;
    }
  }
</style>
<style lang="scss" scoped>
  // .app-container {
  //   background-color: #fff !important;
  // }
  .marginBottom-10 {
    margin-bottom: 10px;
  }

  .marginRight-10 {
    margin-right: 10px;
  }

  .flex {
    display: flex;
  }

  .flex-between {
    display: flex;
    justify-content: space-between;
  }

  .button-box {
    font-size: 14px;
    text-align: right;
    font-size: 12px;

    .inquire-box {
      background: #1890ff;
      color: #ffffff;
    }

    .reset-box {
      background: #eeeeee;
    }
  }

  .app-container {
    background: #f3f5f7;

    .container-module {
      background: #fff;
      padding: 20px;
      border-radius: 5px;

      .title-module {
        font-size: 18px;
      }

      .search-module {
        padding-top: 20px;
        display: block;
      }

      .table-module {
        .table-top {
          margin-bottom: 20px;
        }

        .table-num {
          margin-left: 5px;
          background: #f0f0f0;
          width: 35px;
          border-radius: 5px;
        }
      }
    }
  }
</style>
